<?php

namespace app\controllers;

use app\models\Hello;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;

class HelloController extends Controller
{

    public $defaultAction = 'word';//重写了数据成员

    public function actionTest()
    {
        $model = Hello::find()->where('id >= 1 ')->all();
        var_dump($model[0]->message);
    }

    public function actionLogin()
    {
        $username = $_GET['username'];
        $password = $_GET['password'];

        if($username && $password) {
            if($username == $password) {
                return $this->redirect('/hello/index');
            } else {
                return $this->render('hello', [
                    'message' => '登录失败',
                    'message2' => $password
                ] );
            }
        }

        return $this->render('hello', [
            'message' => '请输入账号密码',
            'message2' => $password
        ] );
    }

    public function actionIndex() //登录成功页
    {


        $word = '登录成功';
        return $this->render('hello', ['message' => $word,'message2' => $word ] );
    }
}
